home *** CD-ROM | disk | FTP | other *** search
/ BMUG Revelations / BMUG Revelations.toast / Programming / Programming Languages / Harvest C / MPW Int & Lib / Interfaces / CursorCtl.h < prev    next >
Text File  |  1991-04-17  |  6KB  |  132 lines

  1. /************************************************************
  2.  
  3. Created: Thursday, September 7, 1989 at 9:11 PM
  4.     CursorCtl.h
  5.     C Interface to the Macintosh Libraries
  6.  
  7.  
  8.     
  9.     <<< CursorCtl - Cursor Control Header File >>>
  10.     
  11.     Copyright Apple Computer, Inc. 1985-1989
  12.     All rights reserved
  13.     
  14.     This file contains:
  15.     
  16.     InitCursorCtl(newCursors) - Init CursorCtl to load the 'acur' resource
  17.     RotateCursor(counter)      - Sequence through cursor frames for counter mod 32
  18.     SpinCursor(increment)      - Sequence mod 32 incrementing internal counter
  19.     Hide_Cursor()              - Hide the current cursor
  20.     Show_Cursor(cursorKind)   - Show the cursor
  21.  
  22. ************************************************************/
  23.  
  24.  
  25. #ifndef __CURSORCTL__
  26. #define __CURSORCTL__
  27.  
  28. enum {HIDDEN_CURSOR,I_BEAM_CURSOR,CROSS_CURSOR,PLUS_CURSOR,WATCH_CURSOR,
  29.     ARROW_CURSOR};
  30. typedef unsigned char Cursors;
  31.  
  32. struct Acur {
  33.     short n;        /*Number of cursors ("frames of film")*/
  34.     short index;    /* Next frame to show <for internal use>*/
  35.     short frame1;    /*'CURS' resource id for frame #1*/
  36.     short fill1;    /*<for internal use>*/
  37.     short frame2;    /*'CURS' resource id for frame #2*/
  38.     short fill2;    /*<for internal use>*/
  39.     short frameN;    /*'CURS' resource id for frame #N*/
  40.     short fillN;    /*<for internal use>*/
  41. };
  42.  
  43. typedef struct Acur acur,*acurPtr,**acurHandle;
  44.  
  45. #ifdef __cplusplus
  46. extern "C" {
  47. #endif
  48. pascal void InitCursorCtl(acurHandle newCursors);
  49. /*
  50.     Initialize the CursorCtl unit. This should be called once prior to calling
  51.     RotateCursor or SpinCursor. It need not be called if only Hide_Cursor or
  52.     Show_Cursor are used. If NewCursors is NULL, InitCursorCtl loads in the
  53.     'acur' resource and the 'CURS' resources specified by the 'acur' resource
  54.     ids.  If any of the resources cannot be loaded, the cursor will not be
  55.     changed.
  56.     
  57.     The 'acur' resource is assumed to either be in the currently running tool or
  58.     application, or the MPW Shell for a tool, or in the System file.  The 'acur'
  59.     resource id must be 0 for a tool or application, 1 for the Shell, and 2 for
  60.     the System file.
  61.     
  62.     If NewCursors is not NULL, it is ASSUMED to be a handle to an 'acur' formatted
  63.     resource designated by the caller and it will be used instead of doing a
  64.     GetResource on 'acur'. Note, if RotateCursor or SpinCursor are called without
  65.     calling InitCursorCtl, then RotateCursor and SpinCursor will do the call for
  66.     the user the first time it is called.  However, the possible disadvantage of
  67.     using this technique is that the resource memory allocated may have
  68.     undesirable affect (fragmentation?) on the application. Using InitCursorCtl
  69.     has the advantage of causing the allocation at a specific time determined by
  70.     the user.
  71.     
  72.     Caution: InitCursorCtl MODIFIES the 'acur' resource in memory.    Specifically,
  73.     it changes each FrameN/fillN integer pair to a handle to the corresponding
  74.     'CURS' resource also in memory.  Thus if NewCursors is not NULL when
  75.     InitCursorCtl is called, the caller must guarantee NewCursors always points to
  76.     a "fresh" copy of an 'acur' resource.  This need only be of concern to a
  77.     caller who wants to repeatly use multiple 'acur' resources during execution of
  78.     their programs.
  79. */
  80.  
  81. pascal void RotateCursor(long counter); 
  82. /*
  83.     RotateCursor is called to rotate the "I am active" "beach ball" cursor, or to
  84.     animate whatever sequence of cursors set up by InitCursorCtl. The next cursor
  85.     ("frame") is used when Counter % 32 = 0 (Counter is some kind of incrementing
  86.     or decrementing index maintained by the caller). A positive counter sequences
  87.     forward through the cursors (e.g., it rotates the "beach ball" cursor
  88.     clockwise), and a negative cursor sequences through the cursors backwards
  89.     (e.g., it rotates the "beach ball" cursor counterclockwise).  Note,
  90.     RotateCursor just does a Mac SetCursor call for the proper cursor picture.
  91.       It is assumed the cursor is visible from a prior Show_Cursor call.
  92. */
  93.  
  94. pascal void SpinCursor(short increment);
  95. /*
  96.     SpinCursor is similar in function to RotateCursor, except that instead of
  97.     passing a counter, an Increment is passed an added to a counter maintained
  98.     here.  SpinCursor is provided for those users who do not happen to have a
  99.     convenient counter handy but still want to use the spinning "beach ball"
  100.     cursor, or any sequence of cursors set up by InitCursorCtl.  A positive 
  101.     increment sequences forward through the curos (rotating the "beach ball"
  102.     cursor clockwise), and a negative increment sequences backward through the
  103.     cursors (rotating the "beach ball" cursor counter-clockwise).  A zero value
  104.     for the increment resets the counter to zero.  Note, it is the increment, and
  105.     not the value of the counter that determines the sequencing direction of the
  106.     cursor (and hence the spin direction of the "beach ball" cursor).
  107. */
  108.  
  109. pascal void Hide_Cursor(void);
  110. /*
  111.     Hide the cursor if it is showing.This is this unit's call to the Mac
  112.     HideCursor routine.Thus the Mac cursor level is decremented by one when this
  113.     routine is called.
  114. */
  115.  
  116. pascal void Show_Cursor(Cursors cursorKind);
  117. /*
  118.     Increment the cursor level, which may have been decremented by Hide_Cursor,
  119.     and display the specified cursor if the level becomes 0 (it is never
  120.     incremented beyond 0).The CursorKind is the kind of cursor to show.  It is
  121.     one of the values HIDDEN_CURSOR, I_BEAM_CURSOR, CROSS_CURSOR, PLUS_CURSOR,
  122.     WATCH_CURSOR, and ARROW_CURSOR. Except for HIDDEN_CURSOR, a Mac SetCursor is
  123.     done for the specified cursor prior to doing a ShowCursor.    HIDDEN_CURSOR just
  124.     causes a ShowCursor call.  Note, ARROW_CURSOR will only work correctly if
  125.     there is already a grafPort set up pointed to by 0(A5).
  126. */
  127. #ifdef __cplusplus
  128. }
  129. #endif
  130.  
  131. #endif
  132.